package cn.openea.perpartner.componet.web.controller;

import cn.openea.perpartner.common.core.web.controller.BaseController;
import cn.openea.perpartner.common.core.web.domain.AjaxResult;
import cn.openea.perpartner.common.core.web.page.TableDataInfo;
import cn.openea.perpartner.componet.web.entity.SmsBlacklist;
import cn.openea.perpartner.componet.web.entity.vo.SmsBlacklistVo;
import cn.openea.perpartner.componet.web.service.ISmsBlacklistService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;


/**
 * 短信黑名单
 *
 * @author ysk
 * @email zane_ysk@qq.com
 * @date 2023-06-13 16:41:18
 */
@Api(tags = "短信黑名单")
@RestController
@RequestMapping("/sms/blacklist")
public class SmsBlacklistController extends BaseController {

    @Resource
    private ISmsBlacklistService smsBlacklistService;

    @ApiOperation(value = "分页查询")
    @GetMapping("/page/list")
    public TableDataInfo pageList(SmsBlacklistVo smsBlacklistVo) {
        startPage();
        List<SmsBlacklist> smsBlacklists = smsBlacklistService.selectListByVo(smsBlacklistVo);
        return getDataTable(smsBlacklists);
    }

    @ApiOperation(value = "新增黑名单")
    @PostMapping("/add")
    public AjaxResult add(@RequestBody SmsBlacklist smsBlacklist) {
        smsBlacklistService.add(smsBlacklist);
        return AjaxResult.success();
    }

    @ApiOperation(value = "移除黑名单")
    @PostMapping("/remove")
    public AjaxResult remove(@RequestBody List<Long> ids) {
        if (ids.isEmpty()) {
            return AjaxResult.error("请选择需要移除的数据");
        }
        smsBlacklistService.deleteByIds(ids);
        return AjaxResult.success();
    }

}
